<extend name="Layout/ins_page" />
<block name="content">
    <link href="/sap/demo.css" rel="stylesheet" type="text/css" />
    <script src="/sap/scripts/boot.js" type="text/javascript"></script>

    <div  id='maoliandxiaoshouForm'>
        <div class="fieldset-body">

            <!--<form method='post' id="maoliandxiaoshouForm" name="maoliandxiaoshouForm" enctype="multipart/form-data"   class="well form-horizontal">-->

            <div>
                <div id="listboxD" name="listboxD" class="mini-listbox" style="width:420px;height:120px;" onvaluechanged="onListBoxValueChanged"
                     url="/Report/getPPList/" showCheckBox="true" multiSelect="true" >
                    <div property="columns">
                        <div header="OA ID" field="id"></div>
                        <div header="品牌名" field="text"></div>
                    </div>
                </div>
            </div>

            <div>
                <div id="listbox" name="listbox" class="mini-listbox" style="width:420px;height:120px;" onvaluechanged="onListBoxValueChanged"
                     url="/Report/getPMList/" showCheckBox="true" multiSelect="true" >
                    <div property="columns">
                        <div header="产品经理" field="id"></div>
                        <div header="上级主管" field="text"></div>
                    </div>
                </div>
            </div>

            <div>
                <a class="mini-button" onclick="search()" enabled="" id='query-bt'  style="width:420px; margin-top: 5px">&nbsp;&nbsp;查询&nbsp;&nbsp;</a>
            </div>

            <div>
                <a class="mini-button" onclick="exportToexcel()" enabled="" id='export-bt'  style="width:420px; margin-top: 5px">&nbsp;&nbsp;导出&nbsp;&nbsp;</a>
            </div>
            <!--</form>-->

            <div id="tabs1" class="mini-tabs" activeIndex="0" style="width:100%;margin-top: 5px;overflow:auto;" plain="false"
                 buttons="#tabsButtons"
            >
                <div title="品牌列表" >

                    <div id="datagrid1" class="mini-datagrid" style="height:430px;width: 100%;"
                         url="/Report/pinpailist20171018data" idField="id"
                         allowResize="true"
                         allowCellEdit="true" allowCellSelect="true" multiSelect="true"
                         allowCellValid="true" oncellvalidation="" showPager="false"
                    >

                        <div property="columns">

                            <div field="U_Brand"  headerAlign="center"  >品牌
                                <input property="" class="mini-textbox" style="width:100%;" />
                            </div>
                            <div field="LV1name"  headerAlign="center"  >一级分类
                                <input property="" class="mini-textbox" style="width:100%;" />
                            </div>
                            <div field="LV2name"  headerAlign="center"  >二级分类
                                <input property="" class="mini-textbox" style="width:100%;" />
                            </div>
                            <div field="LV3name"  headerAlign="center"  >三级分类
                                <input property="" class="mini-textbox" style="width:100%;" />
                            </div>
                            <div field="U_PManager"  headerAlign="center"  >产品经理
                                <input property="" class="mini-textbox" style="width:100%;" />
                            </div>
                            <div field="itemcodecount"  headerAlign="center"  >SKU总数量
                                <input property="" class="mini-textbox" style="width:100%;" />
                            </div>
                            <div field="sale30itemcount"  headerAlign="center"  >动销SKU/月
                                <input property="" class="mini-textbox" style="width:100%;" />
                            </div>


                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>


    </body>

    <script>
        function popBrand(brand) {
            mini.open({
                url:  "Report/pinpaiskulist20171018/pp/"+brand+"/",
                title: brand,
                width: 800,
                height: 380,
                onload: function () {
                    //var iframe = this.getIFrameEl();
                    //var data = { action: "edit", id: row.id };
                    //iframe.contentWindow.SetData(data);
                },
                ondestroy: function (action) {
                    if (action == "ok") {

                    }

                }
            });

        }

        function popBrandbyForm(brand) {
            var f=document.createElement("form");
            f.action="/Report/pinpaiskulist20171018/";
            f.method="post";
            f.target="_blank";
            f.title=brand;
            f.innerHTML=" <input type='hidden' name='brandName' value='"+brand+"'/>";
            document.body.appendChild(f);
            f.submit();
        }
    </script>

    <script type="text/javascript">
        mini.parse();
        var grid = mini.get("datagrid1");
        grid.setPageSize(50000);
        grid.on("drawcell", function (e) {
            var record = e.record,
                column = e.column,
                field = e.field,
                value = e.value;


            //格式化日期
            if (field == "ctime") {
                if (mini.isDate(value)) e.cellHtml = mini.formatDate(value, "yyyy-MM-dd HH:mm:ss");

            }

            if (field == "relevant_link"||field == "similar_brand_link"||field == "top_link") {
                e.cellHtml = '<a href="' + value + '"  target="_blank"  >' +value+ '</a>';
            }

            if (field == "U_Brand") {
                e.cellHtml = "<a href=\"javascript:popBrandbyForm(\'"+record.U_Brand+"\')\" >" +value+ "</a>";
            }

            if (field == "logo") {
                e.cellHtml = '<img src="' + value + '"  style="width:50px" >';
            }

            if (field == "s_price") {
                e.cellHtml = value+"<br>"+record.e_price;
            }

//            if(record.examine_status!=1)
//                e.cellStyle = "background:#f9a8a8";

            if (field == "examine_status") {
                e.cellHtml =value==1?"通过":(value==0?"待审核":'未通过') ;
            }

        });

        function onListBoxValueChanged(e) {
            var listbox = e.sender;
            var value = listbox.getValue();
        }

        function checkPT(pmlist) {

            if(pmlist){}
            else{
                alert('产品经理不能为空');
                return true;
            }
        }

        function checkPP(pplist) {

            if(pplist){}
            else{
                alert('品牌不能为空');
                return true;
            }
        }

        function search(){

            var ppList = mini.get('listboxD').getValue();

            var pmlist = mini.get('listbox').getValue();

//            if(checkPP(ppList))
//            {
//                return;
//            }

            if(checkPT(pmlist))
            {
                return;
            }

            grid.load({ppList:ppList,pmlist:pmlist})
        }

        function exportToexcel(){

            var ppList = mini.get('listboxD').getValue();

            var pmlist = mini.get('listbox').getValue();

//            if(checkPP(ppList))
//            {
//                return;
//            }

            if(checkPT(pmlist))
            {
                return;
            }

            var f=document.createElement("form");
            f.action="/Report/pinpailist20171018excel";
            f.method="post";
            f.innerHTML=" <input type='hidden' name='ppList' value='"+ppList+"'/>"+
                "<input type='hidden' name='pmlist' value='"+pmlist+"'/>"
            ;
            document.body.appendChild(f);
            f.submit();

        }

    </script>
</block>

